The index function extension, SGI_index_func, lets you discard fragments that fail the comparison to a reference value.
The section "Alpha Test" in Chapter 10, "The Framebuffer," of the OpenGL Programming Guide, discusses how in RGBA mode, the alpha test allows you to accept or reject a fragment based on its alpha value. The index function extension is similar but instead of comparing a fragment's alpha value to a reference value, it compares a fragment's index to a reference value.
The index test happens between the scissor test and the alpha test in the per-fragment operations.
To use the extension, call
void IndexFuncSGI (GLenum func, GLclampf ref)
The function sets the reference value and comparison function for the test. The reference value is clamped to be between 0 and 1. The possible values for func are listed on the IndexFuncSGI reference page.
To enable and disable the extension, call glEnable() or glDisable() with GL_INDEX_TEST as the value of the cap parameter. To find out whether index testing is enabled, call glIsEnabled() with the pname parameter of glGetBooleanv(), glGetIntegerv(), glGetFloatv(), and GetDoublev().
To retrieve information about the extension, call glGet*() with one of these arguments:
INDEX_TEST_FUNC
INDEX_TEST_REF